/**
 * @projectName study-note
 * @package Composite
 * @className Composite.Test
 */
package Composite;

/**
 * Test
 * @description 测试类
 * @author answer_wx
 * @date 2022/7/4 10:27
 * @version 1.0
 */
public class Test {
    public static void main(String[] args) {
        /**
         * 根节点
         */
        ConcreteDepartment root = new ConcreteDepartment("root");
        /**
         * 根节点的叶子节点
         */
        root.add(new Leaf("root Leaf A"));
        root.add(new Leaf("root Leaf B"));
        /**
         * 子节点child_a
         */
        ConcreteDepartment child_a = new ConcreteDepartment("child_A");
        child_a.add(new Leaf("child_A Leaf A"));
        root.add(child_a);
        /**
         * 子节点child_b
         */
        ConcreteDepartment child_b = new ConcreteDepartment("child_B");
        /**
         * 孙子节点
         */
        ConcreteDepartment grandson = new ConcreteDepartment("grandson");
        child_b.add(grandson);
        grandson.add(new Leaf("child_B grandson Leaf A"));
        child_b.add(new Leaf("child_B Leaf A"));
        root.add(child_b);
        root.display(1);
    }
}